import { FeatureUnlockPanel } from './ui/FeatureUnlockPanel/FeatureUnlockPanel';

import { Enum } from "cc";
import { PanelConfigInfo, PrefabNameToPanelKeyMap, UIConfig, makePrefabStrToPanelKeyMap } from "../../scripts/libs/ui/UIConfig";

export namespace lobby {

    export enum PanelKey {
        LoadingPanel,
        FrontTipPanel,
        DialogPanel,

        LobbyPanel,
        EditorStageSelectPanel,

        GamePanel,
        GameWinPanel,
        GameLosePanel,

        HardTipPanel,

        SettingsPanel,
        LobbySettingPanel,

        FeatureUnlockPanel,

        EditorGamePanel,
        EditorGameWinPanel,
        EditorGameLosePanel,

        EditorCreatePanel,
        EditorConfirmDialogPanel,

        PlayfabDebugPanel,
    }
    Enum(PanelKey);

    const subgamekey = 'lobby';
    const assetbundle = `ab_${subgamekey}`;


    export const UIConfigList = [
        [PanelKey.LoadingPanel, {
            assetbundle, assetPath: 'Prefabs/LoadingPanel/LoadingPanel',
            tier: 'tier4',
            destroy: false, // 随场景的如果下次还需要，那么不能删
            scene: true,
            name: 'LoadingPanel',
        }],
        [PanelKey.FrontTipPanel, {
            assetbundle, assetPath: 'Prefabs/FrontTipPanel/FrontTipPanel',
            tier: 'tier4',
            destroy: true,
        }],
        [PanelKey.DialogPanel, {
            assetbundle, assetPath: 'Prefabs/DialogPanel/DialogPanel',
            tier: 'tier4',
            destroy: true,
        }],
        [PanelKey.GamePanel, {
            assetbundle, assetPath: 'Prefabs/GamePanel/GamePanel',
            tier: 'game1',
            destroy: true,
        }],
        [PanelKey.GameWinPanel, {
            assetbundle, assetPath: 'Prefabs/GameWinPanel/GameWinPanel',
            tier: 'game1',
            destroy: true,
        }],
        [PanelKey.GameLosePanel, {
            assetbundle, assetPath: 'Prefabs/GameLosePanel/GameLosePanel',
            tier: 'game1',
            destroy: true,
        }],
        [PanelKey.HardTipPanel, {
            assetbundle, assetPath: 'Prefabs/HardTipPanel/HardTipPanel',
            tier: 'tier2',
            destroy: true,
        }],
        [PanelKey.SettingsPanel, {
            assetbundle, assetPath: 'Prefabs/SettingsPanel/SettingsPanel',
            tier: 'tier2',
            destroy: true,
        }],
        [PanelKey.LobbySettingPanel, {
            assetbundle, assetPath: 'Prefabs/LobbySettingPanel/LobbySettingPanel',
            tier: 'tier2',
            destroy: true,
        }],

        [PanelKey.GamePanel, {
            assetbundle, assetPath: 'Prefabs/GamePanel/GamePanel',
            tier: 'game1',
            destroy: true,
        }],

        [PanelKey.LobbyPanel, {
            assetbundle, assetPath: 'Prefabs/LobbyPanel/LobbyPanel',
            tier: 'tier1',
            destroy: true,
        }],

        [PanelKey.FeatureUnlockPanel, {
            assetbundle, assetPath: 'Prefabs/FeatureUnlockPanel/FeatureUnlockPanel',
            tier: 'tier2',
            destroy: true,
        }],

        [PanelKey.EditorStageSelectPanel, {
            assetbundle, assetPath: 'Prefabs/EditorStageSelectPanel/EditorStageSelectPanel',
            tier: 'tier1',
            destroy: true,
        }],

        [PanelKey.EditorGamePanel, {
            assetbundle, assetPath: 'Prefabs/EditorGamePanel/EditorGamePanel',
            tier: 'tier1',
            destroy: true,
        }],

        [PanelKey.EditorGameWinPanel, {
            assetbundle, assetPath: 'Prefabs/EditorGamePanel/EditorGameWinPanel',
            tier: 'game1',
            destroy: true,
        }],

        [PanelKey.EditorGameLosePanel, {
            assetbundle, assetPath: 'Prefabs/EditorGamePanel/EditorGameLosePanel',
            tier: 'game1',
            destroy: true,
        }],

        [PanelKey.EditorCreatePanel, {
            assetbundle, assetPath: 'Prefabs/EditorGamePanel/EditorCreatePanel',
            tier: 'tier1',
            destroy: true,
        }],
        [PanelKey.EditorConfirmDialogPanel, {
            assetbundle, assetPath: 'Prefabs/EditorGamePanel/EditorConfirmDialogPanel',
            tier: 'tier2',
            destroy: true,
        }],

        [PanelKey.PlayfabDebugPanel, {
            assetbundle, assetPath: 'Prefabs/PlayfabDebugPanel/PlayfabDebugPanel',
            tier: 'tier2',
            destroy: true,
        }]
    ];

    // export const UILobbyConfig = new Map<PanelKey, PanelConfigInfo>(UIConfigList as any);

    export function init() {
        UIConfig.set(subgamekey, new Map());
        UIConfigList.forEach(_ => {
            UIConfig.get(subgamekey).set(_[0] as any, _[1] as PanelConfigInfo);
        });
        makePrefabStrToPanelKeyMap(UIConfigList as any, PrefabNameToPanelKeyMap);
    }

    init();

}